import React from 'react'
import ReactDOM from 'react-dom'

// 使用热加载
import { AppContainer } from 'react-hot-loader' // eslint-disable-line
import App from './app/components/App'

import './assets/style/common.less'

// const renderMethod = module.hot ? ReactDOM.render : ReactDOM.hydrate
const renderMethod = ReactDOM.render
const render = (Component) => {
  renderMethod(
    <AppContainer >
      <Component />
    </AppContainer>,
    document.getElementById('root'),
  )
}

render(App)

if (module.hot) {
  module.hot.accept('./app/App.jsx', () => {
    // eslint-disable-next-line
    const newApp = () => import('./app/App.jsx');
    // const newApp = require('./app/App.jsx').default
    render(newApp)
  })
}
